package MapandSetHomeWork;

import java.util.Comparator;
import java.util.TreeSet;

public class TreeSetConstructor {
    public static void main(String[] args) {
        // 空参构造：自然顺序
        TreeSet<String> naturalSet = new TreeSet<>();
        naturalSet.add("Banana");
        naturalSet.add("Apple");
        System.out.println(naturalSet); // 输出 [Apple, Banana]

        // 带Comparator：逆序
        TreeSet<String> customSet = new TreeSet<>(Comparator.reverseOrder());
        customSet.add("Banana");
        customSet.add("Apple");
        System.out.println(customSet); // 输出 [Banana, Apple]
    }
}
